package test;

import dao.DvdDao;
import dao.DvdDaoImpl;
import service.DvdService;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        //DvdDao  数据操作对象声明
        DvdDao dao = new DvdDaoImpl();
        //声明DVD业务操作对象
        DvdService dvdService = new DvdService();

        System.out.println("欢迎使用迷你DVD管理器");
        System.out.println("----------------------");
        label:
        while (true) {
            System.out.println("1.新增DVD");
            System.out.println("2.查看DVD");
            System.out.println("3.删除DVD");
            System.out.println("4.借出DVD");
            System.out.println("5.归还DVD");
            System.out.println("6.退出系统");
            System.out.println("----------------------");
            System.out.println("请选择操作：");
            int i = scanner.nextInt();
            switch (i) {
                case 1:
                    System.out.println("请输入新增DVD名字");
                    String name = scanner.next();
                    System.out.println("请输入DVD的租金");
                    double rent = scanner.nextDouble();
                    dvdService.saveDvd(name, rent);
                    break;
                case 2:
                    System.out.println("---------> 查看DVD信息");
                    System.out.println("序号\t 状态 \t 名称\t借出次数\t借出日期");
                    dvdService.showDVD();
                    break;
                case 3:
                    System.out.println("请输入要删除的DVD名字");
                    name = scanner.next();
                    //执行业务逻辑中的删除
                    dvdService.deleteDvd(name);
                    break;
                case 4:
                    System.out.println("请输入要借阅的DVD名字");
                    name = scanner.next();
                    dvdService.borrow(name);
                    break;
                case 5:
                    System.out.println("请输入要归还的DVD名字");
                    name = scanner.next();
                    dvdService.restitution(name);
                    break;
                case 6:
                    System.out.println("结束程序");
                    break label;
                default:
                    System.out.println("操作有误，请重新选择");
                    break;
            }
        }
    }

}
